package cn.edu.scau.cmi.lishuoxin.interProgramming.experiment5;

import java.util.ArrayList;

public class Folder extends AbstractFiles {
	//文件夹节点的，所有方法都可以用
	private ArrayList<AbstractFiles> list = new ArrayList<AbstractFiles>();
	private String name;
	
	public Folder() {
		
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	@Override
	public void add(AbstractFiles afile) {
		list.add(afile);
		System.out.println("添加成功！");
	}

	@Override
	public void remove(AbstractFiles afile) {
		if(list.remove(afile)) {
			System.out.println("删除成功！");
		}else {
			System.out.println("删除失败！");
		}
	}

	@Override
	public AbstractFiles get(int i) {
		return list.get(i);
	}

	@Override
	public void downloadFile() {
		System.out.println("对"+name+"进行下载...");
		//递归
		for (AbstractFiles af : list) {
			af.downloadFile();
		}
	}
}
